import service from "./index.js";
import gaodeservice from "./gaodeapi.js";

//获取服务器数据
export function getData() {
    return service({
        url: '/getData',
        method: 'get',
    })
}

//获取点击城市景点信息
export function getCityData(name) {
    return service({
        url: '/getCityData',
        method: 'post',
        data: { name }
    })
}
//存储数据
export function putData(name, postpostdata) {
    return service({
        url: '/postCityData',
        method: 'post',
        data: {
            cityname: name,
            data: postpostdata
        }

    })
}
//修改景点信息
export function editSpots(data) {
    return service({
        url: '/editSpotsInfo',
        method: 'post',
        data: data
    })
}
//添加景点信息
export function addSpots(data) {
    return service({
        url: '/addSpotsInfo',
        method: 'post',
        data: data
    })
}
//删除景点信息
export function delSpots(id) {
    return service({
        url: '/delSpotsInfo',
        method: 'post',
        data: {
            id: id
        }
    })
}
// 获取景点美食数据
export function getSpotsFood(location, radius, show_fields = 'navi,business,photos') {
    return gaodeservice({
        url: '/v5/place/around',
        method: 'get',
        params: {
            location: location,
            radius: radius,
            types: '050101|050400|050300|050200',
            key: '245c3be9ba6f5f0a54831c3d5b007aa9',
            show_fields: show_fields,
            page_size: '25'
        }
    })
}
// 获取景点附近住宿
export function getSpotsHouse(location, radius, show_fields = 'navi,business,photos') {
    return gaodeservice({
        url: '/v5/place/around',
        method: 'get',
        params: {
            location: location,
            radius: radius,
            types: '100000',
            key: '245c3be9ba6f5f0a54831c3d5b007aa9',
            show_fields: show_fields,
            page_size: '25'
        }
    })
}
//用户登录
export function userlogin(username, password) {
    return service({
        url: '/userlogin',
        method: 'post',
        data: {
            username,
            password
        }
    })
}
//用户注册
export function userregiter(username, password, email) {
    return service({
        url: '/userregiter',
        method: 'post',
        data: {
            username,
            password,
            email
        }
    })
}
//ai对话
export function chatai(message) {
    return service({
        url: '/chatai',
        method: 'post',
        data: JSON.stringify([
            {
                Role: "user",
                Content: message
            }
        ])
    })
}
